package com.max.eshop.UI.executer;

import com.max.eshop.UI.userinterface.Action;
import com.max.eshop.UI.userinterface.Input;
import com.max.eshop.services.Services;

public class Executer {
	Input input = new Input();
	private final static String nextMenu = "**************************************************";
	Services service = new Services();
	public Executer(){
		service.load("");
	}

	public void execute(Action action) {
		
		if (action.equals(Action.executeOrder)) {
			service.getOrderService().sortedByStatus();
			service.getOrderService().show();
			Integer i;
			do {
				System.out.println(nextMenu);
				System.out.println("Kakoi zakaz vipolnitb?");
				i = input.inputInformation();				
			} while (service.getOrderService().count() <= i);
			System.out.println(nextMenu);
			service.getOrderService().execute(i);
			System.out.println(nextMenu);
			service.getOrderService().show();
			System.out.println(nextMenu);
		}
		if(action.equals(Action.deleteOrder)){
			service.getOrderService().show();
			Integer i;
			do {
				System.out.println(nextMenu);
				System.out.println("Kakoi zakaz ydalitb?");
				i = input.inputInformation();				
			} while (service.getOrderService().count() <= i);
			System.out.println(nextMenu);
			service.getOrderService().delete(i);
			service.getOrderService().show();
			System.out.println(nextMenu);
			}
		if(action.equals(Action.deleteBook)){
			service.getBookService().sortedByAlphabet();
			service.getBookService().show();
			Integer i;
			do {
				System.out.println(nextMenu);
				System.out.println("Kakoi zakaz ydalitb?");
				i = input.inputInformation();				
			} while (service.getBookService().count() <= i);
			System.out.println(nextMenu);
			service.getBookService().delete(i);
			service.getBookService().show();
			System.out.println(nextMenu);
		}
		if(action.equals(Action.addBook)){
			System.out.println(nextMenu);
			System.out.println("Dobovlenie Knigi");
			System.out.println("Vvedite Nazvanie Knigi");
			String name=input.inputString();
			System.out.println("Vvedite datu publikacii");
			String dateOfPublication=input.inputString();
			System.out.println("Vvedite opisenie");
			String  description=input.inputString();
			System.out.println("Vvedite count");
			Integer count=input.inputInformation();	
			System.out.println("Vvedite price");
			Integer  price=input.inputInformation();	
			service.getBookService().add(name, dateOfPublication, description, count, price);
			System.out.println("Dobavleno");
		}
		if(action.equals(Action.addOrder)){
			System.out.println(nextMenu);
			System.out.println("Dobovlenie Zakaza");
			System.out.println("Vvedite Nazvanie Knigi");
			String name=input.inputString();
			System.out.println("Vvedite count");
			Integer count=input.inputInformation();
			service.getOrderService().add(name, count);
			System.out.println("Dobavleno");
		}
		

	}
}
